package cae.logic;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;

import cae.logic.destination.CaeDestination;


public class CaeMessageSender
{
	public static void sendMessage(String message, CaeDestination destination) throws IOException
	{
		Socket s = new Socket();
		s.connect(new InetSocketAddress(destination.getMachine()[0], destination.getPort()));
		
		CaeMessageStub stub = new CaeMessageStub(message);
		ObjectOutputStream oos = new ObjectOutputStream(s.getOutputStream());
		oos.writeObject(stub);
		
		oos.close();
		
		//new OutputStreamWriter( s.getOutputStream() ).append(message).close();
		
	}
}
